<template>  
    <input type="file" @change="handleFileUpload" accept=".xlsx, .xls" />  
  </template>  
    
  <script setup>  
  import axios from 'axios';  
    
  const handleFileUpload = async (event) => {  
    const file = event.target.files[0];  
    const formData = new FormData();  
    formData.append('file', file);  
    
    try {  
      await axios.post('/api/upload', formData, {  
        headers: {  
          'Content-Type': 'multipart/form-data'  
        }  
      });  
      alert('文件上传成功！');  
    } catch (error) {  
      console.error('上传失败:', error);  
    }  
  };  
  </script>